<?php

class Application_Form_Bet extends Zend_Form
{
	public function __construct($action=null){
		parent::__construct();
		$this->setAction($action);
	}
    public function init()
    {
		$this->setMethod('post');
		$score_left = new Zend_Form_Element_Text('bet_left');
        $score_left->setOptions(array('size' => 5))
        		->setRequired(true)
        		->addValidator('Int')
        		->addValidator('GreaterThan', false, array('min' => -1));
        $score_left->setDecorators(array('ViewHelper', 'Description', 'Errors',
        		array(
        			array('data' => 'HtmlTag'), 
        			array('tag' => 'td')),
        		array(
        			'Label', 
        			array('tag' => 'td')),
        		array(
        			array('row' => 'HtmlTag'),
        			array('tag' => 'tr', 'openOnly' => 'true'))
        			));
        $score_right = new Zend_Form_Element_Text('bet_right');
        $score_right->setOptions(array('size' => 5))
        		->setRequired(true)
        		->addValidator('Int')
        		->addValidator('GreaterThan', false, array('min' => -1));
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('BET!');

        $this->addElements(array($score_left, $score_right, $submit));
    	$this->setDecorators(array(
               'FormElements',
               array(
               	array('data'=>'HtmlTag'),array('tag'=>'table')),
               'Form'));
    }
	public function fillForm($bet_id){
		if(!$bet_id){
			return 0;
		}
		$bet_tbl = new Application_Model_DbTable_Bet();
		$bet = $bet_tbl->GetBetsById((int)$bet_id, null, null, null, false)->current();
		$this->populate($bet->toArray());
		// Populate dates
		/*else{
			$date_now = new Zend_Date();
			$this->date_start->setValue($date_now);
		}*/

	}
}

